#include "managerwidget.h"

ManagerWidget::ManagerWidget(QWidget *parent) : QWidget(parent)
{
    init_Widget();
    init_Control();
    init_Connect();
}

void ManagerWidget::init_Control()
{
    //按钮
    this->checkuserBtn=new QPushButton();
    this->checkuserBtn->setText(QString::fromUtf8("查看用户信息"));
    this->checkuserBtn->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);


    this->changeuserBtn=new QPushButton();
    this->changeuserBtn->setText(QString::fromUtf8("修改用户信息"));
    this->changeuserBtn->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);


    this->deletuserBtn=new QPushButton();
    this->deletuserBtn->setText(QString::fromUtf8("删除用户信息"));
    this->deletuserBtn->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);


    this->adduserBtn=new QPushButton();
    this->adduserBtn->setText(QString::fromUtf8("添加用户信息"));
    this->adduserBtn->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);


    this->changeThingsBtn=new QPushButton();
    this->changeThingsBtn->setText(QString::fromUtf8("修改物品数据"));
    this->changeThingsBtn->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);

    this->changeTimeBtn=new QPushButton();
    this->changeTimeBtn->setText(QString::fromUtf8("修改出入库记录"));
    this->changeTimeBtn->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);



    this->manageLay=new QVBoxLayout();
    this->manageLay->addWidget(this->checkuserBtn);
    this->manageLay->addWidget(this->changeuserBtn);
    this->manageLay->addWidget(this->deletuserBtn);
    this->manageLay->addWidget(this->adduserBtn);
    this->manageLay->addWidget(this->changeThingsBtn);
    this->manageLay->addWidget(this->changeTimeBtn);

//    this->hlay->addLayout(this->manageLay);
//    this->hlay->addStretch(1);
    this->setLayout(this->manageLay);
}

void ManagerWidget::init_Widget()
{

    this->setWindowTitle(QString::fromUtf8("管理窗口"));
    this->resize(800,600);
    //this->setLayout(this->hlay);
    this->CheckWidget=new CheckUserWidget();
    this->adduserWidget=new AddUserWidget();
   this->deleteWidget=new DeleteUserWidget();
    this->alterWidget=new AlterWidget();
    this->changeThingsWidget=new ChangeThingsWidget();
    this->changeTimeWidget=new ChangeTimeWidget();
}

void ManagerWidget::init_Connect()
{
    qDebug()<<"jinrule";
    connect(this->checkuserBtn,SIGNAL(clicked()),this,SLOT(on_checkuserBtn_cliked()));
    connect(this->changeuserBtn,SIGNAL(clicked()),this,SLOT(on_changeuserBtn_cliked()));
    connect(this->CheckWidget,SIGNAL(returnWidget()),this,SLOT(showMyself()));
    //connect(this->list,SIGNAL(itemClicked(QListWidgetItem*)),this,SLOT(on_list_cliked(QListWidgetItem*)));
    connect(this->adduserBtn,SIGNAL(clicked()),this,SLOT(on_adduserBtn_cliked()));
    connect(this->adduserWidget,SIGNAL(returnManager()),this,SLOT(showMyself()));
    connect(this->alterWidget,SIGNAL(returnManager()),this,SLOT(showMyself()));
    connect(this->deleteWidget,SIGNAL(returnManager()),this,SLOT(showMyself()));
    connect(this->changeThingsWidget,SIGNAL(returnManager()),this,SLOT(showMyself()));
    connect(this->deletuserBtn,SIGNAL(clicked()),this,SLOT(on_deletuserBtn_cliked()));
    connect(this->changeThingsBtn,SIGNAL(clicked()),this,SLOT(on_changeThingsBtn_cliked()));
     connect(this->changeTimeBtn,SIGNAL(clicked()),this,SLOT(on_changeTimeBtn_cliked()));
     connect(this->changeTimeWidget,SIGNAL(returnManager()),this,SLOT(showMyself()));


}

void ManagerWidget::on_checkuserBtn_cliked()
{
    this->hide();
    this->CheckWidget->CheckInfomation();
    this->CheckWidget->show();
}

void ManagerWidget::on_adduserBtn_cliked()
{

    this->hide();
    this->adduserWidget->show();

}

void ManagerWidget::on_deletuserBtn_cliked()
{
    this->hide();
    this->deleteWidget->show();
}
void ManagerWidget::on_changeuserBtn_cliked()
{
    this->hide();
    this->alterWidget->show();
}

void ManagerWidget::on_changeThingsBtn_cliked()
{
   this->hide();
    this->changeThingsWidget->show();
}

void ManagerWidget::on_changeTimeBtn_cliked()
{
    this->hide();
     this->changeTimeWidget->show();
}


void ManagerWidget::showMyself()
{
    //qDebug()<<"返回";
    this->CheckWidget->close();
    this->adduserWidget->close();
    this->deleteWidget->close();
    this->alterWidget->close();
    this->changeThingsWidget->close();
    this->show();
}
